home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGSCAL / TBUTIL2.LZH / BENCHMRK.PAS next >
Pascal/Delphi Source File  |  1984-08-27  |  967b  |  39 lines

  1. PROGRAM BENCH_MARK;
  2. {  This program was converted from BASIC into Pascal.
  3.  
  4.    FLOATING-POINT BENCHMARK
  5.  
  6.    The following is a program to test the accuracy of floating
  7.    point functions (from Sept. DR DOBBS):
  8.       10 A=1
  9.       20 FOR I%=1 TO 2499
  10.       30   A=TAN(ATN(EXP(LOG(SQR(A*A))))) + 1
  11.       40 NEXT
  12.       50 PRINT A
  13.       60 STOP
  14.  
  15.    The correct printout is A=2500 exactly.
  16.  
  17.    IBM-PC BASIC 1.0 fails miserably, giving A=2179.8 (only 1 sig-
  18.    nificant figure of accuracy!).  In contrast, an APPLE II or
  19.    Commodore 64 gives 2500 to at least 7 figures. Using the 8087
  20.    with a polyFORTH version of the benchmark, I obtained 2500 to
  21.    13 figures in 5.0 seconds. (NOTE: See March,84 D. DOBBS for
  22.    the results aginst many systems.)
  23. }
  24.  
  25.  
  26. VAR
  27.   a : REAL;
  28.   i : INTEGER;
  29.  
  30. BEGIN
  31.   a:=1;
  32.   FOR i:= 1 TO 2499 DO
  33.   BEGIN
  34.     a:= ARCTAN( EXP( LN(SQRT(a * a)) ) );
  35.     a:= (SIN(a) / COS(a)) + 1;
  36.   END;
  37.   WRITELN(a:3:11);
  38. END.
  39.